package chpt07;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

public class OtherExceptionTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		testClassForName();
		testPrintWriter();		
	}
	
    
	public static void testClassForName(){
		String clazzName = "一个不存在的类名";
		String className = "RuntimeExceptionTest";
		try {
			Class.forName(clazzName); //载入字符串代表的类
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		System.out.println("============end of testClassForName============");
		
	}
	
    //演示文件类型异常
	public static void testPrintWriter(){
		PrintWriter out = null;
		String fileName = "一个不存在的文件.txt";
		
		try {
			out = new PrintWriter(fileName);
			out.println("test write");
			out.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.out.println("找不到该文件："+fileName);
		}finally{
			if(out != null)
				out.close();
		}
		
		System.out.println("============end of testPrintWriter============");
	}
	
	

}
